import Vue from "vue";
import Vuex from "@/libs/my-vuex";
Vue.use(Vuex);
export default new Vuex.Store({
  state: {
    count: 1,
  },
  getters: {
    doubleCount(state) {
      return state.count * 2;
    },
  },
  mutations: {
    addCount(state, num) {
      state.count += num;
    },
  },
  actions: {
    asyncAddCount({ commit }, num) {
      setTimeout(() => {
        commit("addCount", num);
      }, 1000);
    },
  },
});
